﻿<%@ page pageEncoding="UTF-8" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head> 
	<title>CrecheBook</title>
	<!-- meta -->
	<meta name="description" content="">
	<meta name="author" content="M. Steve">
	<link rel="shortcut icon" href="favicon.ico">
	<meta charset="UTF-8">
	
	<!-- CSS-->
	<link rel="stylesheet" href="medias/css/core.css" type="text/css" media="screen">
	
	<!-- JS -->
	<script src="medias/javaScript/inputs.js"></script>
	
	<!-- Google MAPS -->
	<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
	
	<!-- JQuery -->
	<meta name="viewport" content="width=device-width, initial-scale=1"> 
	<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
	<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
	<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
	
</head> 
<body > 

	<%@ page import = "Creche.Bd.BD" %>
	<%@page import = "Creche.Main.Creche"%>
	<%@page import = "Creche.Admin.Administrateur" %>
	<%@page import = "Creche.Personne.Personne"%>
	<%@page import = "Creche.Donnees.Adresse"%>
	<%@page import = "Creche.Donnees.Modification" %>
	<%@page import = "Creche.Donnees.Donnee" %>
	<%@page import = "Creche.Donnees.Actualite" %>
	<%@page import = "java.util.ArrayList" %>
	<%@page import = "java.lang.String" %>
	<%@page import = "java.io.*" %>
	<%@page import = "java.util.*" %>
	<%@page import = "javax.servlet.*" %>
	<%@page import = "java.sql.Date" %>
	<%@page import = "java.text.SimpleDateFormat" %>
	<%@page import = "java.text.DateFormat" %>
	


	<div data-role="page">
	
		<div data-role="header">
		
			
			
			<div id="banniere">
				<br>
				<br>
				<h1 >CrecheBook</h1>
			</div>
			
			<div id="searchBox">
	
				<div class="ui-bar ui-bar-c">	
					<h2 id="nomCreche">
						<a href='search.jsp' rel='external' data-role='button' data-theme='c' data-corners='true' data-icon='home' data-inline='true'>Accueil</a>
						Administration
					</h2>
	
				 </div>
			 </div>
				
				
	 
		</div><!-- /header -->
	
		<div data-role="content">
			<!-- Modifier ici -->
			<div class="ui-grid-a">
				<div class="ui-block-a">
				
					<div id="menu">
			
							<a href="accueilAdmin.jsp"><p id="socialLink"><img src="medias/images/919406.jpg.png" width="50" height="50"/><span>Informations</span></p></a>
							<a href="inscriptions_adm.jsp"><p id="socialLink"><img src="medias/images/1367190697_sign-up_1_small.png" width="50" height="50"/><span>Inscriptions</span></p></a>
							
					
					<%
						// Redirection
						Administrateur admin = (Administrateur)request.getSession().getAttribute("session");
				
						if (admin != null) {
							if (admin.getStatut()) {
								out.print("<a href='code' data-ajax='false'><p id='socialLink'><img src='medias/images/key.png' width='50' height='50'/><span>Codes admin</span></p></a>");
							}
						}
						else response.sendRedirect("connexion");
					%>
					</div>
			
			
				</div><!-- /menu-->
				
				<div class="ui-block-b">
				
					<div class="ui-bar ui-bar-b" >
						<h2> Informations personnelles </h2>
					</div>
				
					<div id="informationGenerale">
		
													
					<%
						if (admin != null) {
							session.setAttribute("creche", null);
							String infoCreche = "<p class='col'>";
							infoCreche += "<strong> ID : </strong>" + admin.getIdentifiant() +"<br/>";
							infoCreche += "<strong> Email : </strong>" + admin.getEmail()+"<br/>";
							infoCreche += "<strong> Ville : </strong>" + admin.getVille() +"</p>";
							
							infoCreche += "<p style='margin:auto;width:250px;'><a href='deconnexion' data-ajax='false'><input type='button' data-theme='a' value='D&#233;connexion' class='button1'></a></p>";
							out.print(infoCreche);
						}
					%>
						
					
		
				
					</div> 
				
				</div>	   <!-- /infoGenerale-->
	
			</div> <!-- /ui-block-b-->
			<br>
			
			<div class="ui-bar ui-bar-c">
				<h2> Actualités </h2>
			</div>
			
			
			
			
			 <div id="actualitee">
			 
				<br>
				<br>
									
				<%

					
					if (admin != null) {
						BD myBase = new BD();
						ArrayList<Modification> listeModif = (ArrayList<Modification>)myBase.getModif();
						ArrayList<Donnee> listeDonnee;
						ArrayList<Actualite> listeActualite;
						//parcours des modifications on va afficher toutes les modifs
						// que l'amdin à le droit de valider
						//avec un lien hypertexte pour modifier la page
						for(int i =0; i < listeModif.size(); i++) 
						{	
							Creche courrante = myBase.getCreche(listeModif.get(i).getIdModif());
							if (courrante.getAdresse().getVille().equals(admin.getVille()) ||
									admin.getStatut()) {
								String villeC = listeModif.get(i).getIdModif();
								String nom = villeC.split(":")[1];
								villeC = villeC.split(":")[0];
								out.print("<div data-role='collapsible' data-theme='c' data-content-theme='d' data-collapsed='false'><h3>"+ villeC+" | " + nom + "</h3>");
								out.print("<h5>Informations personnelles</h5>");
								//String href = "<a style='text-decoration:none;color:withe;' href =\"creche.jsp?nom=" + listeModif.get(i).getNomCreche() + "&ville="+ villeC +"\">" ;
								String titre = listeModif.get(i).getNomCreche();
								listeDonnee = courrante.getSeulementDonnees();
								listeActualite = courrante.getActu();
								//parcours de la liste des donn?es
								// on va chercher les donn?es qui sont invalides et les afficher
								
								for(int j = 0; j < listeDonnee.size(); j++) {
									if(!listeDonnee.get(j).valide()) {
										out.print("<form method = POST action = validation>");
										out.print("<input type = 'hidden' name ='nomC' value = \"" + courrante.getAdresse().getVille()
																										+ ":" + 
																										courrante.getNom() + "\">");
										out.print( listeDonnee.get(j).getLabel() + " ");
										String addS ="";
										addS += "<div class='ui-grid-c'>";
										addS += "	<div class='ui-block-b'>";
										addS += "		<input data-mini='true' type ='text' name ='"+listeDonnee.get(j).getLabel()+"' value = '"+listeDonnee.get(j).getVal()+"'>";
										addS += "	</div>";
										addS += "	<div class='ui-block-c'>";
										addS += "		<input type ='submit' value = 'Sauvegarder' data-mini='true' data-theme='b'></form>";
										addS += "	</div>";
										addS += "</div>";
										out.print(addS);
									}
								}
								
								out.print("<h5>Evènements</h5>");
								
								// on va parcourrir les actualit?s non valides
								for(int j = 0; j < listeActualite.size(); j++ ){
									if(!listeActualite.get(j).valide()) {
										SimpleDateFormat formatDateJour = new SimpleDateFormat("dd/MM/yyyy");
										String dateFormatee = formatDateJour.format(listeActualite.get(j).getDate()); 
										out.println("<div data-role='collapsible' data-theme='b' data-content-theme='c' data-collapsed='false'><h4>" + 
											listeActualite.get(j).getLabel()+ "&nbsp; -&nbsp;"+dateFormatee+"</h4><br><form name = 'actu' action = 'validation' method = 'POST'>" +listeActualite.get(j).getVal()+
											"<br><br><input type = 'hidden' name = 'nomActu' value ='" + listeActualite.get(j).getLabel() +
											"'>"+ "<input type = 'hidden' name ='nomC' value = \"" + courrante.getAdresse().getVille()
											+ ":" + 
											courrante.getNom() + "\">");
											
										String addS ="";
										addS += "<div class='ui-grid-c'>";
										addS += "	<div class='ui-block-a'></div>";
										addS += "	<div class='ui-block-b'></div>";
										addS += "	<div class='ui-block-c'>";
										addS += "		<input type = 'submit' name ='Valider' value ='Valider' data-theme='b' data-mini='true'>";
										addS += "	</div>";
										addS += "	<div class='ui-block-d'>";
										addS += "		<input type = 'submit' name = \"Supprimer\" value = 'Supprimer' data-theme='c' data-mini='true'>";
										addS += "	</div>";
										addS += "</div>";
										addS += "</form></p></div><br><br>";
										out.print(addS);
	
									}
								}
								
								out.print("</div>");
								
										 
							}
						}

					}
					out.print("<br><br>"); 
				
				%>
		
			</div><!-- /actualitee -->
			
			<br>
			<br>

			
		</div><!-- /content -->
	
		<div data-role="footer">
			
			<h4 style="margin:30px;">
				<strong> CrecheBook 2013</strong> <br>
				<a href="legal.jsp" data-ajax="false">Mentions&nbsp;l&eacute;gales</a>&nbsp;|&nbsp;
				<a href="connexion" data-ajax="false">Administateur</a>
			</h4>
				
		</div><!-- /footer -->
	</div><!-- /page -->

</body>
</html>